package com.ashok.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport implements SessionAware{
	private static final Logger LOGGER = LoggerFactory
			.getLogger(LoginAction.class);

	private String username;
	private String password;
	private Map<String, Object> session;
	
	public String execute() {

		LOGGER.info("User Name :" + username);
		LOGGER.info("Password :" + password);
		if (username.equals("ashok") && password.equals("admin")) {
			session.put("user", username);
			return SUCCESS;
		} else {
			addActionError("Invalid username or password");
			return INPUT;
		}
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session=session;
		
	}

}
